﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Pixysoft.Framework.Sockets
{
    class SettingHelper
    {
        public static int default_interval_command_nonduplicate = 100;//min interval for non-duplicate command

        public static int default_interval_command_duplicate = 100;//min interval for duplicate command

        public static int default_interval_trigger_connection = 1000 * 60 * 3;// interval for checking timeout connection.



        public static int default_timeout_connection = 1000 * 60 * 5;// the timeout for connection when no request.

        public static int default_timeout_login = 1000 * 60;// the timeout for connection not login.

        public const int default_timeout_socket_send = 1000;// 1000 * 60 * 1; //1 min socket链接超时的时间

        public const int default_timeout_socket_receive = 1000;// 1000 * 60 * 1; //1 min socket链接超时的时间



        public static int default_max_socket_error = 3;// the max error of socket (wrong protocol / exception ...)

        public static int default_max_socket_frequency = 10;// the max frequence for socket communication. must list then command interval.

        public static int default_max_connnection_socket = 10000;// the capacity for connection pool.



        public static int default_interval_sync_send = 1000 * 10;


        public static void Initialize(SocketConfiguration config)
        {
            config.Verify();

            LoggerHelper.Info("setting::default_interval_command_duplicate = {0}", config.IntervalCommandDuplicate);
            default_interval_command_duplicate = config.IntervalCommandDuplicate;
            LoggerHelper.Info("setting::default_interval_command_nonduplicate = {0}", config.IntervalCommandNonDuplicate);
            default_interval_command_nonduplicate = config.IntervalCommandNonDuplicate;
            LoggerHelper.Info("setting::default_interval_trigger_connection = {0}", config.IntervalTriggerConnection);
            default_interval_trigger_connection = config.IntervalTriggerConnection;

            LoggerHelper.Info("setting::default_timeout_connection = {0}", config.TimeoutConnection);
            default_timeout_connection = config.TimeoutConnection;
            LoggerHelper.Info("setting::default_timeout_login = {0}", config.TimeoutLogin);
            default_timeout_login = config.TimeoutLogin;

            LoggerHelper.Info("setting::default_max_socket_error = {0}", config.MaxSocketError);
            default_max_socket_error = config.MaxSocketError;
            LoggerHelper.Info("setting::default_max_socket_frequency = {0}", config.MaxSocketFrequency);
            default_max_socket_frequency = config.MaxSocketFrequency;
            LoggerHelper.Info("setting::default_max_connnection_socket = {0}", config.MaxConnectionSocket);
            default_max_connnection_socket = config.MaxConnectionSocket;

            LoggerHelper.Info("setting::default_interval_sync_send = {0}", config.IntervalSyncSend);
            default_interval_sync_send = config.IntervalSyncSend;
        }
    }
}
